<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        #imgSlide li {
            list-style: none;
            display: none;
        }

        #container {
            position: relative;
            width: 960px;
            height: 373px;
            margin: 0px auto;
        }

        #imgBar li {
            cursor: pointer;
            width: 20px;
            height: 20px;
            border: 1px solid #ccc;
            float: left;
            text-align: center;
            line-height: 20px;
            list-style: none;
            margin-left: 2px;
        }

        #imgBar {
            position: absolute;
            top: 50px;
            left: 50px;

        }

        #imgBar li.on {
            background-color: rgb(red, green, blue, .5);
        }
    </style>
</head>

<body>
    <div id="container">
        <ul id="imgSlide">
            <li><img src="./素材/1.png" alt=""></li>
            <li><img src="./素材/2.png" alt=""></li>
            <li><img src="./素材/3.png" alt=""></li>
            <li><img src="./素材/4.png" alt=""></li>
            <li><img src="./素材/5.png" alt=""></li>
        </ul>
        <ul id="imgBar">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>
    </div>
    <script>
        var container = document.getElementById("container");
        var imgBar = document.getElementById("imgBar")
        var lis = document.getElementById("imgBar").getElementsByTagName("li")
        var imgs = document.getElementById("imgSlide").getElementsByTagName("li");
        var first = last = 0;
        function autoSlide() {
            timer = setInterval(function () {
                slide();
                first = first + 1;
                if (first > 4) {
                    first = 0;
                }
            }, 1000
            )
        }
        function stopInterval() {
            clearInterval(timer);
        }
        function slide() {
            imgs[last].style.display = "none";
            lis[last].classList.remove("on");
            imgs[first].style.display = "block";
            lis[first].classList.add("on");
            last = first;
        }
        imgBar.onmouseover = function (e) {
            but = e.target;
            if (but.nodeName == "LI") {
                first = parseInt(but.innerHTML, 10) - 1;
                slide();

            }
        }
        imgs[first].style.display = "block";
        autoSlide();
        container.onmouseover = stopInterval;
        container.onmouseout = autoSlide;
    </script>
</body>

</html>